package com.ruoyi.web.controller.qx;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.QxChestnutAdoptModelHistory;
import com.ruoyi.system.service.IQxChestnutAdoptModelHistoryService;

/**
 * 树苗认领记录Controller
 * 
 * @author ruoyi
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/system/history")
public class QxChestnutAdoptModelHistoryController extends BaseController
{
    @Autowired
    private IQxChestnutAdoptModelHistoryService qxChestnutAdoptModelHistoryService;

    /**
     * 查询树苗认领记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(QxChestnutAdoptModelHistory qxChestnutAdoptModelHistory)
    {
        startPage();
        List<QxChestnutAdoptModelHistory> list = qxChestnutAdoptModelHistoryService.selectQxChestnutAdoptModelHistoryList(qxChestnutAdoptModelHistory);
        return getDataTable(list);
    }

    /**
     * 导出树苗认领记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "树苗认领记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QxChestnutAdoptModelHistory qxChestnutAdoptModelHistory)
    {
        startPage();
        this.qxChestnutAdoptModelHistoryService.exportHistoryListToExcelService(response,qxChestnutAdoptModelHistory);
    }

    /**
     * 获取树苗认领记录详情
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{treeId}")
    public AjaxResult getInfo(@PathVariable("treeId") Long treeId)
    {
        return success(qxChestnutAdoptModelHistoryService.selectQxChestnutAdoptModelHistoryByTreeId(treeId));
    }
}
